/*
===========================================================================
Copyright (C) 2005 Sarunas

This file is part of MyPIRC source code.

DisksDB source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

DisksDB source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with DisksDB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/
using System;
using System.Collections.Generic;
using System.Text;

namespace MyIRC
{
	public class IrcConfig : Config
	{
		private IrcConfig() : base("")
		{
			string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);

			if ((false == "".Equals(path)) && (path[path.Length - 1] != '\\'))
			{
				path += "\\";
			}

			path = path + cfgName;

			base.fileName = path;

			base.Load();

			this.showTime = base.GetValue("ShowTime", false);
			this.showJoins = base.GetValue("ShowJoins", false);
			this.showParts = base.GetValue("ShowParts", false);
			this.showQuits = base.GetValue("ShowQuits", false);
		}

		public static IrcConfig Instance
		{
			get
			{
				if (null == instance)
				{
					instance = new IrcConfig();
				}

				return instance;
			}
		}

		public void SaveConfig()
		{
			base.Save();
		}

		public string Server
		{
			get
			{
				return base.GetValue("Server", "irc.omnitel.net");
			}
			set
			{
				base.SetValue("Server", value);
			}
		}

		public int Port
		{
			get
			{
				return base.GetValue("Port", 6667);
			}
			set
			{
				base.SetValue("Port", value);
			}
		}

		public string NickName
		{
			get
			{
				return base.GetValue("NickName", "PocketUser-" + Guid.NewGuid().ToString());
			}
			set
			{
				base.SetValue("NickName", value);
			}
		}

		public string RealName
		{
			get
			{
				return base.GetValue("RealName", "My Pocket IRC");
			}
			set
			{
				base.SetValue("RealName", value);
			}
		}

		public string Password
		{
			get
			{
				return base.GetValue("Password", "");
			}
			set
			{
				base.SetValue("Password", value);
			}
		}

		public string User
		{
			get
			{
				return base.GetValue("User", "mypirc");
			}
			set
			{
				base.SetValue("User", value);
			}
		}

		public bool ShowTime
		{
			get
			{
				return this.showTime;
			}
			set
			{
				this.showTime = value;
				base.SetValue("ShowTime", value);
			}
		}

		public bool ShowJoins
		{
			get
			{
				return this.showJoins;
			}
			set
			{
				this.showJoins = value;
				base.SetValue("ShowJoins", value);
			}
		}

		public bool ShowParts
		{
			get
			{
				return this.showParts;
			}
			set
			{
				this.showParts = value;
				base.SetValue("ShowParts", value);
			}
		}

		public bool ShowQuits
		{
			get
			{
				return this.showQuits;
			}
			set
			{
				this.showQuits = value;
				base.SetValue("ShowQuits", value);
			}
		}

		private bool showTime = false;
		private bool showJoins = false;
		private bool showParts = false;
		private bool showQuits = false;
		private static IrcConfig instance = null;
		private static string cfgName = "mypirc.cfg";
	}
}
